home *** CD-ROM | disk | FTP | other *** search
- /************************************************************************
- * *
- * The SB-Prolog System *
- * Copyright SUNY at Stony Brook, 1986; University of Arizona, 1987 *
- * *
- ************************************************************************/
-
- /*-----------------------------------------------------------------
- SB-Prolog is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY. No author or distributor
- accepts responsibility to anyone for the consequences of using it
- or for whether it serves any particular purpose or works at all,
- unless he says so in writing. Refer to the SB-Prolog General Public
- License for full details.
-
- Everyone is granted permission to copy, modify and redistribute
- SB-Prolog, but only under the conditions described in the
- SB-Prolog General Public License. A copy of this license is
- supposed to have been given to you along with SB-Prolog so you
- can know your rights and responsibilities. It should be in a
- file named COPYING. Among other things, the copyright notice
- and this notice must be preserved on all copies.
- ------------------------------------------------------------------ */
-
- #include "inst.h"
- #include "sim.h"
-
-
- #define printop1(tp) \
- fprintf(fd, "\t %x",(tp)oprnd1) ; fflush(stdout)
- #define printop2(tp) \
- fprintf(fd, "\t %x",(tp)oprnd2) ; fflush(stdout)
- #define printop3(tp) \
- fprintf(fd, "\t %x",(tp)oprnd3) ; fflush(stdout)
-
- print_inst(fd, inst_ptr)
- FILE *fd;
- byte *inst_ptr;
- {
- byte *lpcreg; /* local pc register for macros to use */
- byte opcode; int i;
- lpcreg = inst_ptr;
- if (num_line) fprintf(fd,"%x\t",lpcreg);
- opcode = *lpcreg++;
- fprintf(fd, inst_name[opcode]);
- switch (parse_table[opcode]) {
-
- case E: break;
-
- case PBB: parse_opPBB;
- printop1(byte);
- printop2(byte);
- break;
-
- case BBB: parse_opBBB;
- printop1(byte);
- printop2(byte);
- printop3(byte);
- break;
-
- case BC:
- case BW: parse_opBW;
- printop1(byte);
- printop2(word);
- break;
-
- case B: parse_opB;
- printop1(byte);
- if (opcode == hash) {
- fprintf(fd, "\n");
- for (i = 0; i < oprnd1; i++) {
- if (num_line) fprintf(fd, "%x\t", lpcreg);
- fprintf(fd, "\t %x\n", *((pw)lpcreg));
- lpcreg += 4;
- }
- }
- break;
-
- case PC:
- case PW: parse_opPW;
- printop1(word);
- break;
-
- case PL: parse_opPL;
- printop1(long);
- break;
-
- case BA: parse_opBA;
- printop1(byte);
- printop2(word);
- break;
-
- case BAA: parse_opBAA;
- printop1(byte);
- printop2(word);
- printop3(word);
- if (opcode == switchonbound) { /* I don't understand this
- code, didn't write it, and refuse to be
- responsible for it. It doesn't seem to work
- right anyway. --SKD */
- fprintf(fd, "\n");
- if (num_line) fprintf(fd, "%x\t", lpcreg);
- opcode = *lpcreg++;
- fprintf(fd, inst_name[opcode]);
- parse_opPA;
- printop1(word); fprintf(fd, "\n");
- for (i = 0; i < oprnd3; i++) {
- if (num_line) fprintf(fd, "%x\t", lpcreg);
- fprintf(fd, "\t %x\n", *((pw)lpcreg));
- lpcreg += 4;
- }
- }
- break;
-
- case PA: parse_opPA;
- printop1(word);
- break;
-
- case BL: parse_opBL;
- printop1(byte);
- printop2(long);
- break;
-
- case P: parse_opP;
- if (opcode == noop) lpcreg += 2 * oprnd1;
- break;
- } /* end switch */
- pcreg = lpcreg;
- fprintf(fd, "\n");
- } /* print_inst */
-
-
-